//package com.plian.system.controller.fr.vehicle;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.Func;
//import com.plian.Tools.StringPool;
//import com.plian.Tools.StringUtil;
//import com.plian.Tools.base.BaseController;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.config.Resubmit;
//import com.plian.system.entity.fr.vehicle.VehicleInfo;
//import com.plian.system.enumeratea.CarStatus;
//import com.plian.system.model.CommonCode;
//import com.plian.system.model.ListResult;
//import com.plian.system.model.R;
//import com.plian.system.model.token.PassToken;
//import com.plian.system.mybatis.search.SearchParamEntiy;
//import com.plian.system.mybatis.search.TokenSearch;
//import com.plian.system.mybatis.support.Condition;
//import com.plian.system.mybatis.support.Query;
//import com.plian.system.service.fr.vehicle.IVehicleInfoService;
//import com.plian.system.vo.fr.vehicle.VehicleInfoVO;
//import com.plian.system.wrapper.fr.veihicle.VehicleInfoWrapper;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.AllArgsConstructor;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
///**
// * @description:车辆信息
// * @author: gangan
// * @create: 2020-03-08 11:56
// */
//
//@RestController
//@RequestMapping("api/vehicleinfo")
//@AllArgsConstructor
//@Api(value = "车辆信息", tags = "车辆信息controller")
//public class VehicleInfoController extends BaseController {
//
//    private final IVehicleInfoService vehicleInfoService;
//    private final VehicleInfoWrapper vehicleInfoWrapper;
//
//    /**
//     * 详情
//     */
//    @PostMapping("/detail")
//    @ApiOperation(value = "详情 id")
//    public R<VehicleInfoVO> detail(@RequestBody VehicleInfo vehicleInfo) {
//        return R.data(vehicleInfoService.detail(vehicleInfo));
//    }
//
//    /**
//     * 分页
//     */
//    @PostMapping("/list")
//    @ApiOperation(value = "列表 分页")
//    public ListResult<VehicleInfoVO> list(@RequestBody Query query) {
//        if (query.getAscs() == null && query.getDescs() == null){
//            query.setAscs("company_rank_id");
//            query.setDescs("company_id,create_time");
//        }
//        QueryWrapper<VehicleInfo> queryWrapper = SearchParamEntiy.getQueryWrapper(
//                Condition.getQueryWrapper(new VehicleInfo()), query.getSearch()
//        );
//
//        if (StringUtil.isNotBlank(query.getKeyword())){
//            queryWrapper.and(wrapper -> wrapper.lambda()
//                    .like(VehicleInfo::getNumberPlate, query.getKeyword())
//                    .or().eq(VehicleInfo::getDisposalVehicleNumberPlate, query.getKeyword()));
//        }
//        queryWrapper.lambda().eq(VehicleInfo::getIsShow, 1);
//        TokenSearch<VehicleInfo> tokenSearch = new TokenSearch<>();
//        tokenSearch.addTokenQuery(queryWrapper, query);
//
//        IPage<VehicleInfo> pages = vehicleInfoService.page(Condition.getPage(query), queryWrapper);
//        List<VehicleInfoVO> vehicleInfoVOS = vehicleInfoWrapper.entityToVO(pages.getRecords());
//        if (CollectionUtil.isNotEmpty(vehicleInfoVOS)){
//            for (VehicleInfoVO vehicleInfoVO : vehicleInfoVOS){
//                vehicleInfoService.changeTransferVO(vehicleInfoVO);
//                if (StringUtil.isBlank(vehicleInfoVO.getNumberPlate()) && StringUtil.isNotBlank(vehicleInfoVO.getDisposalVehicleNumberPlate())){
//                    vehicleInfoVO.setNumberPlate(vehicleInfoVO.getDisposalVehicleNumberPlate());
//                }
//            }
//        }
//        ListResult<VehicleInfoVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(vehicleInfoVOS);
//        listResult.setTotal(Long.valueOf(pages.getTotal()).intValue());
//        return listResult;
//    }
//
//
//    /**
//     * 新增或修改
//     */
//    @PostMapping("/submit")
//    @Resubmit(delaySeconds = 0)
//    @ApiOperation(value = "提交")
//    public R<VehicleInfoVO> submit(@RequestBody VehicleInfoVO vehicleInfoVO) {
//       return R.data(vehicleInfoService.submit(vehicleInfoVO));
//    }
//
//
//    /**
//     * 补充信息(车辆状态为拟处置可进行操作)
//     */
//    @PostMapping("/add-disposal-info")
//    @Resubmit(delaySeconds = 0)
//    @ApiOperation(value = "补充信息(车辆状态为拟处置可进行操作)")
//    public R addDisposalInfo(@RequestBody VehicleInfoVO vehicleInfoVO) {
//        return R.status(vehicleInfoService.addDisposalInfo(vehicleInfoVO));
//    }
//
//
//    /**
//     * 修改信息(车辆状态为在用且单据状态为已审批)
//     */
//    @PostMapping("/change-info")
//    @Resubmit(delaySeconds = 0)
//    @ApiOperation(value = "修改信息(车辆状态为在用且单据状态为已审批)")
//    public R changeInfo(@RequestBody VehicleInfoVO vehicleInfoVO) {
//        return R.status(vehicleInfoService.changeInfo(vehicleInfoVO));
//    }
//
//    /**
//     * 删除
//     */
//    @PostMapping("/remove")
//    @ApiOperation(value = "删除")
//    public R remove(@RequestBody PageData pd) {
//        List<String> ids = (List<String>) pd.get("ids");
//        return R.status(vehicleInfoService.deleteLogic(Func.toLongList(StringUtils.join(ids, StringPool.COMMA))));
//    }
//
//
//    /**
//     * 分页
//     */
//    @GetMapping("/list/{companyId}")
//    public ListResult<VehicleInfoVO> getByCompanyId(@PathVariable String companyId) {
//        QueryWrapper<VehicleInfo> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("status", CarStatus.USING.getStatus());
//        queryWrapper.eq("company_id", companyId);
//        List<VehicleInfoVO> vehicleInfoVOS = vehicleInfoWrapper.entityToVO(vehicleInfoService.list(queryWrapper));
//        ListResult<VehicleInfoVO> listResult = new ListResult<>(CommonCode.SUCCESS);
//        listResult.setList(vehicleInfoVOS);
//        return listResult;
//    }
//
//    @GetMapping("/get-init-data/{companyId}")
//    public R<VehicleInfoVO> getInitData(@PathVariable String companyId){
//        return R.data(vehicleInfoService.getInitData(companyId));
//    }
//
//    @GetMapping("/buildword/{id}")
//    @PassToken
//    @ApiOperation(value = "导出审批单", notes = "传入id")
//    public void buildword(@PathVariable Long id, HttpServletResponse response) {
//        vehicleInfoService.buildword(id,response);
//    }
//
//    @PostMapping(value = "/uploadFile",produces="application/json;charset=UTF-8")
//    @ApiOperation(value = "导入", notes = "传入导入文件")
//    public R uploadFile(@RequestParam("file") MultipartFile multipartFile) {
//        vehicleInfoService.uploadFile(multipartFile);
//        return R.success();
//    }
//    @PostMapping("/transfer")
//    @ApiOperation(value = "划转")
//    public R<VehicleInfo> transfer(@RequestBody VehicleInfoVO vehicleInfoVO){
//        return R.data(vehicleInfoService.transfer(vehicleInfoVO));
//    }
//
//}
